package com.example.yjhticket.controller;

import com.example.yjhticket.entity.Orders;
import com.example.yjhticket.service.OrderService;
import com.yc.yjh.entity.Result;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/order")
public class OrdersController {

    @Resource
    OrderService orderService;

    @RequestMapping("/add")
    public Result addOrder(@RequestBody Orders order){
        final int i = orderService.addOrder(order);
        if (i>0){
            return  Result.success("购买成功");
        }else {
            return Result.error("业务异常");
        }
    }

    @RequestMapping("/get")
    public Result getOrderByID(String id){
        final List<Orders> orderByID = orderService.getOrderByID(id);
        return Result.success("OK",orderByID);
    }
}
